package com.woniu.micropropertyserver.feign.service.fallback;

import com.alibaba.fastjson.JSONObject;
import com.woniu.microcommonsserver.param.ResponseMsg;
import com.woniu.micropropertyserver.feign.service.MicroProjectServerFeign;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @author ：bb
 * @date ：Created in 2021/2/3 0003
 * @description：
 * @modified By：
 * @version: $
 */
@Component
public class MicroProjectServerFallbackFactory implements FallbackFactory<MicroProjectServerFeign> {

    @Override
    public MicroProjectServerFeign create(Throwable throwable) {

        throwable.printStackTrace();
        //匿名内部类

        return new MicroProjectServerFeign() {
            @Override
            public ResponseMsg findById(String id) {
                return ResponseMsg.builder().
                        code(10000).msg("根据参数查询项目，已达熔断阈值！").build();
            }

            @Override
            public ResponseMsg findAll() {
                return ResponseMsg.builder().
                        code(10000).msg("根据查询所有项目，已达熔断阈值！").build();
            }
        };
    }
}
